package com.zhentao.websocket.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用于封装浏览器发送给服务端的消息数据
 * 支持私聊和群聊消息
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Message {
    private Integer fromId;
    private Integer toId;
    private String toName; // 私聊时的接收者用户名
    private String message; // 消息内容
    private String messageType = "text"; // 消息类型：text, image, voice, video, file
    private String chatType = "private"; // 聊天类型：private(私聊), group(群聊)
    private Long groupId; // 群聊时的群组ID

    // 图片消息相关字段
    private Long fileSize; // 文件大小（字节）
    private String originalFilename; // 原始文件名

    // 视频消息相关字段
    private Long videoDuration; // 视频时长（秒）
    private Integer videoWidth; // 视频宽度
    private Integer videoHeight; // 视频高度
    private String videoCoverUrl; // 视频封面图URL
    private String toAvatar; // 接收方头像URL

/*    public String getToAvatar() {
        return toAvatar;
    }

    public void setToAvatar(String toAvatar) {
        this.toAvatar = toAvatar;
    }

    public void setFromId(Integer fromId) {
        this.fromId = fromId;
    }

    public void setToId(Integer toId) {
        this.toId = toId;
    }

    public Integer getFromId() {
        return fromId;
    }

    public Integer getToId() {
        return toId;
    }

    public String getToName() {
        return toName;
    }

    public void setToName(String toName) {
        this.toName = toName;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessageType() {
        return messageType;
    }

    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }

    public String getChatType() {
        return chatType;
    }

    public void setChatType(String chatType) {
        this.chatType = chatType;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    public Long getFileSize() {
        return fileSize;
    }

    public void setFileSize(Long fileSize) {
        this.fileSize = fileSize;
    }

    public String getOriginalFilename() {
        return originalFilename;
    }

    public void setOriginalFilename(String originalFilename) {
        this.originalFilename = originalFilename;
    }

    public Long getVideoDuration() {
        return videoDuration;
    }

    public void setVideoDuration(Long videoDuration) {
        this.videoDuration = videoDuration;
    }

    public Integer getVideoWidth() {
        return videoWidth;
    }

    public void setVideoWidth(Integer videoWidth) {
        this.videoWidth = videoWidth;
    }

    public Integer getVideoHeight() {
        return videoHeight;
    }

    public void setVideoHeight(Integer videoHeight) {
        this.videoHeight = videoHeight;
    }

    public String getVideoCoverUrl() {
        return videoCoverUrl;
    }

    public void setVideoCoverUrl(String videoCoverUrl) {
        this.videoCoverUrl = videoCoverUrl;
    }*/

//    *
//     * 判断是否为群聊消息

    public boolean isGroupMessage() {
        return "group".equals(chatType) && groupId != null;
    }

//    *
//     * 判断是否为私聊消息

    public boolean isPrivateMessage() {
        return "private".equals(chatType) && toName != null && !toName.trim().isEmpty();
    }

/*    @Override
    public String toString() {
        return "Message{" +
                "fromId=" + fromId +
                ", toId=" + toId +
                ", toName='" + toName + '\'' +
                ", message='" + message + '\'' +
                ", messageType='" + messageType + '\'' +
                ", chatType='" + chatType + '\'' +
                ", groupId=" + groupId +
                ", fileSize=" + fileSize +
                ", originalFilename='" + originalFilename + '\'' +
                ", videoDuration=" + videoDuration +
                ", videoWidth=" + videoWidth +
                ", videoHeight=" + videoHeight +
                ", videoCoverUrl='" + videoCoverUrl + '\'' +
                '}';
    }*/
}
